<template>
  <svg :class="svgClass" aria-hidden="true" :style="{ color: color }">
    <use :xlink:href="symbolId" />
  </svg>
</template>
 
<script setup>
import { computed } from 'vue'
const props = defineProps({
  prefix: {
    type: String,
    default: 'icon',
  },
  name: {
    type: String,
    required: true,
  },
  color: {
    type: String,
    default: '#333',
  },
  active: {
    type: Boolean,
    default: false,
  },
})
const symbolId = computed(() => `#${props.prefix}-${props.name}`)

const svgClass = computed(() => {
  let cls = ['svg-icon']
  props.name && cls.push(`icon-${props.name}`)
  props.active && cls.push(`svg-icon--active`)

  return cls.join(' ')
})
</script>

<style scoped>
.svg-icon {
  width: 1.2em;
  height: 1.2em;
  vertical-align: -0.18em;
  fill: currentColor;
  overflow: hidden;
}
</style>